using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DomainLayer.Data.Entities;

namespace Infrastructure.Data.Mapping
{
	public class GPSOrderMap : EntityTypeConfiguration<GPSOrder>
	{
		public GPSOrderMap()
		{
			// Primary Key
			this.HasKey(t => t.orderno);

			// Properties
			this.Property(t => t.orderno)
				.IsRequired()
				.HasMaxLength(32);
				
			this.Property(t => t.city)
				.HasMaxLength(20);
				
			this.Property(t => t.warehouse)
				.HasMaxLength(32);
				
			this.Property(t => t.stations)
				.HasMaxLength(50);
				
			this.Property(t => t.address)
				.HasMaxLength(120);
				
			this.Property(t => t.gpsid)
				.HasMaxLength(16);
				
			this.Property(t => t.truckno)
				.IsFixedLength()
				.HasMaxLength(16);
				
			// Table & Column Mappings
			this.ToTable("GPSOrder");
			this.Property(t => t.orderno).HasColumnName("orderno");
			this.Property(t => t.city).HasColumnName("city");
			this.Property(t => t.warehouse).HasColumnName("warehouse");
			this.Property(t => t.stations).HasColumnName("stations");
			this.Property(t => t.cid).HasColumnName("cid");
			this.Property(t => t.address).HasColumnName("address");
			this.Property(t => t.lng).HasColumnName("lng");
			this.Property(t => t.lat).HasColumnName("lat");
			this.Property(t => t.createtime).HasColumnName("createtime");
			this.Property(t => t.gpsid).HasColumnName("gpsid");
			this.Property(t => t.time).HasColumnName("time");
			this.Property(t => t.truckno).HasColumnName("truckno");
			this.Property(t => t.IsSyn).HasColumnName("IsSyn");
		}
	}
}

